-
Notifications
You must be signed in to change notification settings - Fork 0
Batch Conversion Action Between Sql Annotations and SQL Files #460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
A comprehensive implementation of bulk conversion functionality between @Sql annotations and SQL files at the DAO class level, with improved SQL formatting stability for large injected SQL strings.
Key changes include:
- Added two new intention actions for bulk conversion operations on DAO classes
- Enhanced SQL formatting processors with improved PSI-safe processing and injection handling
- Updated test suite with comprehensive test coverage for bulk conversion scenarios
Reviewed Changes
Copilot reviewed 62 out of 62 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| BulkConvertSqlAnnotationToFileAction.kt | Core implementation for bulk @SQL annotation to SQL file conversion |
| BulkConvertSqlFileToAnnotationAction.kt | Core implementation for bulk SQL file to @SQL annotation conversion |
| SqlFormatPreProcessor.kt | Major refactoring with PSI-safe fast processing and improved injection handling |
| SqlInjectionPostProcessor.kt | Updated to handle formatting for injected SQL with explicit main logic calls |
| SqlAnnotationConverter.kt | Enhanced annotation creation with proper indentation and formatting |
| Test files (*.sql, *.java) | Comprehensive test data for bulk conversion scenarios |
| Bundle properties | Localization support for new bulk conversion actions |
| plugin.xml | Registration of new intention actions with proper ordering |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/main/kotlin/org/domaframework/doma/intellij/formatter/processor/SqlFormatPreProcessor.kt
Show resolved
Hide resolved
src/main/kotlin/org/domaframework/doma/intellij/formatter/processor/SqlFormatPreProcessor.kt
Show resolved
Hide resolved
src/main/kotlin/org/domaframework/doma/intellij/action/dao/SqlAnnotationConverter.kt
Outdated
Show resolved
Hide resolved
@Sql Annotations and SQL Files…date method signatures
…otations(support for version 2023.3)
Summary
This PR introduces an intention action that allows batch conversion between
@Sqlannotations and SQL files at the DAO class level.Execution Conditions
The action is available only when:
The target class is a DAO class, and
At least one method meets the conversion conditions:
@Sql, orDetails
@Sqlannotation are excluded from processing. They will not be formatted automatically, and require manual execution of the format action.@Sqlannotations: The corresponding SQL file is formatted first (for performance reasons), and then the formatted content is injected into the annotation.Injection SQL Handling
When formatting large SQL strings (e.g., injected SQL with ~1000 lines) within
@Sqlannotations, errors could occur.To address this:
SqlFormatPreProcessorno longer runs on injected SQL.SqlInjectionPostProcessor.Impact